package thread;

public class Demo13 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

        });
        //在start之前获取，获取到的是线程还未创建的状态
        System.out.println(t.getState());//NEW
        t.start();
        Thread.sleep(500);
        System.out.println(t.getState());//RUNNABLE 加上了Thread.sleep(500);之后TIMED_WAITING
        t.join();
        //在join之后获取，获取到的是线程已经结束的状态
        System.out.println(t.getState());//TERMINATED
    }
}
